package com.duowei.diandan.bean.food;

import com.duowei.diandan.constant.MenuItemType;

import java.util.Objects;
import java.util.UUID;

/**
 * 菜单项
 */
public class FoodItem implements FoodImpl {

    private UUID cateUuid;

    private MenuItemType menuItemType = MenuItemType.TYPE_ITEM;

    private FoodImpl food;

    private String name;

    public FoodItem() {
    }

    public UUID getCateUuid() {
        return cateUuid;
    }

    public void setCateUuid(UUID cateUuid) {
        this.cateUuid = cateUuid;
    }

    public MenuItemType getMenuItemType() {
        return menuItemType;
    }

    public void setMenuItemType(MenuItemType menuItemType) {
        this.menuItemType = menuItemType;
    }

    @Override
    public String getImgNo() {
        return food != null ? food.getImgNo() : null;
    }

    public String getName() {
        if (MenuItemType.TYPE_HEADER == this.menuItemType) {
            return name;
        } else {
            return food != null ? food.getName() : null;
        }
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public Float getPrice() {
        return food != null ? food.getPrice() : null;
    }

    @Override
    public Float getMemberPrice() {
        return food != null ? food.getMemberPrice() : null;
    }

    @Override
    public Float getXl() {
        if (this.food != null) {
            return this.food.getXl();
        } else {
            return null;
        }
    }

    public FoodImpl getFood() {
        return food;
    }

    public void setFood(FoodImpl food) {
        this.food = food;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof FoodItem) {
            FoodItem fi = (FoodItem) obj;

            return this.menuItemType == fi.menuItemType
                    && Objects.equals(this.food, fi.food);
        } else {
            return false;
        }
    }
}
